﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="WxNotify.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：WxNotify.cs
// 创建时间：2014-12-25 12:58
// 修改时间：2014-12-23 10:44
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

namespace Payment.Weixin2
{
    #region

    using System;
    using System.IO;
    using System.Text;
    using System.Web;

    using Newtonsoft.Json;

    #endregion

    /// <summary>
    /// The wx notify.
    /// </summary>
    public class WxNotify
    {
        #region Public Properties

        /// <summary>
        /// Gets the attach.
        /// </summary>
        public string attach { get; set; }

        /// <summary>
        /// Gets the bank billno.
        /// </summary>
        public string bank_billno { get; set; }

        /// <summary>
        /// Gets the bank type.
        /// </summary>
        public string bank_type { get; set; }

        /// <summary>
        /// Gets the discount.
        /// </summary>
        public string discount { get; set; }

        /// <summary>
        /// Gets the fee type.
        /// </summary>
        public string fee_type { get; set; }



        /// <summary>
        /// Gets the input charset.
        /// </summary>
        public string input_charset { get; set; }


        /// <summary>
        /// Gets the notify id.
        /// </summary>
        public string notify_id { get; set; }


        /// <summary>
        /// Gets the out trade no.
        /// </summary>
        public string out_trade_no { get; set; }


        /// <summary>
        /// Gets the partner.
        /// </summary>
        public string partner { get; set; }


        /// <summary>
        /// Gets the product fee.
        /// </summary>
        public string product_fee { get; set; }


        /// <summary>
        /// Gets the sign type.
        /// </summary>
        public string sign_type { get; set; }


        /// <summary>
        /// Gets the signtrade mode.
        /// </summary>
        public string trade_mode { get; set; }


        /// <summary>
        /// Gets the time end.
        /// </summary>
        public string time_end { get; set; }


        /// <summary>
        /// Gets the total fee.
        /// </summary>
        public string total_fee { get; set; }



        /// <summary>
        /// Gets the trade state.
        /// </summary>
        public string trade_state { get; set; }


        /// <summary>
        /// Gets the transaction id.
        /// </summary>
        public string transaction_id { get; set; }


        /// <summary>
        /// Gets the transport fee.
        /// </summary>
        public string transport_fee { get; set; }


        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// 获取通知json
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string GetPostJson()
        {
            return JsonConvert.SerializeObject(this);
        }

        /// <summary>
        /// 获取通知InputStream数据
        /// </summary>
        /// <param name="inputStream">
        /// The input Stream.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string GetXml(Stream inputStream)
        {
            var strLen = Convert.ToInt32(inputStream.Length);
            var strArr = new byte[strLen];
            inputStream.Read(strArr, 0, strLen);

            // 字符串
            var requestMes = Encoding.UTF8.GetString(strArr);

            ////保存文件
            // File.WriteAllBytes("", strArr);
            inputStream.Close();
            return requestMes;
        }

        #endregion
    }
}